import 'package:flutter/material.dart';
import 'package:flutter_ahj_app/app/qingning/home/QNViewModel.dart';
import 'package:flutter_ahj_app/base/basewidget/view/BaseWidget.dart';
import 'package:flutter_ahj_app/base/utils/JUIKit/JText.dart';
import 'package:flutter_ahj_app/base/utils/mTopBar.dart';
import 'package:flutter_ahj_app/base/values/SQColor.dart';
import 'package:flutter_ahj_app/base/values/dimens.dart';
import 'package:tcard/tcard.dart';

class QNHomePage extends BaseStatefulWidget {
  @override
  State<StatefulWidget> initState() {
    // TODO: implement initState
    // throw UnimplementedError();
    return QNHomePageState();
  }
}

class QNHomePageState extends BaseState<QNViewModel, QNHomePage> {
  List<String> images = [
    'https://pics7.baidu.com/feed/023b5bb5c9ea15ce0ba4e03794dffefe3b87b2b6.jpeg@f_auto?token=b9edf5dfb8fffd1cfe310758d15e0465',
    'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2024%2F0508%2F099cbfcdj00sd5u9q0042d000u001e0p.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
    'http://img0.baidu.com/it/u=1608394765,3851491798&fm=253&app=138&f=JPEG?w=800&h=1686',
    'http://img1.baidu.com/it/u=451053437,3547976485&fm=253&app=138&f=JPEG?w=800&h=1717',
    'http://img2.baidu.com/it/u=3400859320,1888908530&fm=253&app=138&f=JPEG?w=800&h=1512',
    'http://img1.baidu.com/it/u=808379644,2882929906&fm=253&app=138&f=JPEG?w=800&h=1676',
    'http://img2.baidu.com/it/u=4260309315,3136688663&fm=253&app=138&f=JPEG?w=800&h=1609',
    'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2024%2F0508%2F6156d795j00sd5ub6003qd000tq01fup.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
    'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2024%2F0508%2Ff7ab769dj00sd5uaj002ud000u001fop.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
    'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2024%2F0508%2Ff54c8262j00sd5ubb004gd000tk01fvp.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
    'https://pic.rmb.bdstatic.com/bjh/events/91236edfedba3305eb9828603aee58b42466.jpeg@h_1280',
    'https://img1.baidu.com/it/u=3840503498,2436942629&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=728',
    'https://b0.bdstatic.com/ugc/c9FRKxIruCVsIGgzlCuYYQf0d85622e0aee89ebd73d1b6bbd66541.jpg@h_1280'
  ];
  List<Widget> _cards = List();
  @override
  void initState() {
    // TODO: implement initState
    super.initState();

    _cards = List.generate(
      images.length,
          (int index) {
        return Container(
          decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.circular(16.0),
            boxShadow: [
              BoxShadow(
                offset: Offset(0, 17),
                blurRadius: 23.0,
                spreadRadius: -13.0,
                color: Colors.black54,
              )
            ],
          ),
          child: ClipRRect(
            borderRadius: BorderRadius.circular(16.0),
            child: Image.network(
              images[index],
              fit: BoxFit.cover,
            ),
          ),
        );
      },
    );
  }

  @override
  Widget initWidget() {
    return Scaffold(
      resizeToAvoidBottomInset: true,
      backgroundColor: Color(0xfff4f5f6),
      bottomSheet: BottomAppBar(),
      body: _bodyView(),
    );
  }

  _bodyView() {
    return SingleChildScrollView(
      child: Column(
        children: [
          SafeArea(child: Container()),
          Row(
            children: [
              Expanded(
                child: Container(
                  decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(8.0),
                      image: DecorationImage(
                          fit: BoxFit.fill,
                          image: AssetImage(
                            "img/home_cp.png",
                          ))),
                  margin: EdgeInsets.only(left: 15, right: 5),
                  height: 100,
                  child: Container(
                    margin: EdgeInsets.only(left: 10),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        JText(
                          '分配CP',
                          color: SQColor.white,
                          fontSize: 15,
                          fontWeight: FontWeight.bold,
                        ),
                        JText(
                          '查看详情',
                          color: SQColor.per90White,
                          fontSize: 12,
                        ),
                      ],
                    ),
                  ),
                ),
              ),
              Expanded(
                child: Container(
                  decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(8.0),
                      image: DecorationImage(
                          fit: BoxFit.fill,
                          image: AssetImage(
                            "img/home_jg.png",
                          ))),
                  margin: EdgeInsets.only(left: 5, right: 15),
                  height: 100,
                  child: Container(
                    margin: EdgeInsets.only(left: 10),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        JText(
                          '声音酒馆',
                          color: SQColor.white,
                          fontSize: 15,
                          fontWeight: FontWeight.bold,
                        ),
                        JText(
                          '今日剩余3次',
                          color: SQColor.per90White,
                          fontSize: 12,
                        ),
                      ],
                    ),
                  ),
                ),
              ),
            ],
          ),
          Container(
            child: Row(
              children: [
                Expanded(
                  child: Container(
                    decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(4.0),
                        image: DecorationImage(
                            fit: BoxFit.fill,
                            image: AssetImage(
                              "img/home_pp.png",
                            ))),
                    margin: EdgeInsets.only(left: 15, right: 5, top: 10),
                    height: 80,
                    child: Container(
                      margin: EdgeInsets.only(left: 10),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: [
                          JText(
                            '在线匹配',
                            color: SQColor.white,
                            fontSize: 13,
                            fontWeight: FontWeight.bold,
                          ),
                          JText(
                            '今日剩余25次',
                            color: SQColor.per90White,
                            fontSize: 10,
                          ),
                        ],
                      ),
                    ),
                  ),
                ),
                Expanded(
                  child: Container(
                    decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(4.0),
                        image: DecorationImage(
                            fit: BoxFit.fill,
                            image: AssetImage(
                              "img/home_yqw.png",
                            ))),
                    margin: EdgeInsets.only(left: 5, right: 7, top: 10),
                    height: 80,
                    child: Container(
                      margin: EdgeInsets.only(left: 10),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: [
                          JText(
                            '一起玩',
                            color: SQColor.white,
                            fontSize: 15,
                            fontWeight: FontWeight.bold,
                          ),
                          JText(
                            '寻找游戏搭子',
                            color: SQColor.per90White,
                            fontSize: 12,
                          ),
                        ],
                      ),
                    ),
                  ),
                ),
                Expanded(
                  child: Container(
                    decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(4.0),
                        image: DecorationImage(
                            fit: BoxFit.fill,
                            image: AssetImage(
                              "img/home_yq.png",
                            ))),
                    margin: EdgeInsets.only(left: 5, right: 15, top: 10),
                    height: 80,
                    child: Container(
                      margin: EdgeInsets.only(left: 10),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: [
                          JText(
                            '邀请好友',
                            color: SQColor.white,
                            fontSize: 15,
                            fontWeight: FontWeight.bold,
                          ),
                          JText(
                            '分享心动信号',
                            color: SQColor.per90White,
                            fontSize: 12,
                          ),
                        ],
                      ),
                    ),
                  ),
                ),
              ],
            ),
          ),
          _tccard()
        ],
      ),
    );
  }

  _tccard() {
    return Container(margin: EdgeInsets.all(Dimens.dimens16),
    child: TCard(
      size: Size(400, 600),
      cards: _cards,
     ),
    );
  }


}
